package com.test.demo1.service.impl;
import com.github.pagehelper.PageHelper;
import com.test.demo1.bean.Projects;
import com.test.demo1.common.BaseServiceImpl;
import com.test.demo1.common.PageRequest;
import com.test.demo1.mapper.ProjectsMapper;
import com.test.demo1.service.ProjectsService;
import com.test.demo1.util.SnowflakeIdGenerator;
import org.springframework.stereotype.Service;
import java.util.List;
import com.github.pagehelper.PageInfo;
import java.lang.Integer;
/**
 * 项目信息表(Projects)表服务实现类
 *
 * @author makejava
 * @since 2025-07-22 23:11:50
 */
@Service
public class ProjectsServiceImpl extends BaseServiceImpl<Projects,Integer> implements ProjectsService {
    
    private final ProjectsMapper projectsMapper;
    public ProjectsServiceImpl(ProjectsMapper projectsMapper){
    this.projectsMapper=projectsMapper;
    }
    /**
     * 分页查询
     *
     * @param projects 筛选条件
     * @return 查询结果
     */
    @Override
    public PageInfo<Projects> queryByPage(PageRequest<Projects> request) {
    Projects requestParam = request.getParam();
        if (requestParam==null){
            requestParam=new Projects();
        }
        PageHelper.startPage(request.getPageIndex(),request.getPageSize());
        List<Projects> list =projectsMapper.queryAll(requestParam);
        return new PageInfo<>(list);
    }
    
     @Override
    public void saveOrUpdate(Projects request) {
        
            if (request.getId()==null){
                request.setId(SnowflakeIdGenerator.nextId());
                //saveOrUpdate(request);
                mapper.insertSelective(request);
                return;
            }
            updateById(request);
    }
    
    @Override
    public void delete(Projects projects) {
        mapper.delete(projects);
    }

    @Override
    public void insertBatch(Projects projects, List<Projects> projectss) {
        projectsMapper.insertBatch(projects,projectss);
    }
}
